﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Hotel
{
    public partial class CustomerManagement : Form
    {
        public CustomerManagement()
        {
            InitializeComponent();
        }
        CNDatabase cnDb = new CNDatabase();

        private void CustomerManagement_Load(object sender, EventArgs e)
        {
            string qr = "select  * from Customer";
            grvCustomer.DataSource = cnDb.getDataset(qr).Tables[0];
            lbCustomer.Text = "Total customer: " + cnDb.getOneData("select COUNT(1) from Customer");
        }

        private void txtIden_TextChanged(object sender, EventArgs e)
        {
            string qr = "select  * from Customer where IdentificationNumber like N'%" + txtIden.Text + "%'";
            grvCustomer.DataSource = cnDb.getDataset(qr).Tables[0];
        }

        private void txtPhone_TextChanged(object sender, EventArgs e)
        {
            string qr = "select  * from Customer where PhoneNumber like N'%" + txtPhone.Text + "%'";
            grvCustomer.DataSource = cnDb.getDataset(qr).Tables[0];
        }

        private void txtFind_TextChanged(object sender, EventArgs e)
        {
            string qr = "select  * from Customer where Fullname like N'%" + txtName.Text + "%'";
            grvCustomer.DataSource = cnDb.getDataset(qr).Tables[0];
        }

        private void rb1_Click(object sender, EventArgs e)
        {
            txtName.BringToFront();
            txtPhone.Text = "";
            txtIden.Text = "";
        }

        private void rb2_Click(object sender, EventArgs e)
        {
            txtPhone.BringToFront();
            txtName.Text = "";
            txtIden.Text = "";
        }

        private void rb3_Click(object sender, EventArgs e)
        {
            txtIden.BringToFront();
            txtName.Text = "";
            txtPhone.Text = "";
        }

        
    }
}
